const BASE_URL = 'http://192.168.1.18:30000/xinggc';

// 添加拦截器
const httpIntercepor = {



	// 拦截前触发
	invoke(options : UniApp.RequestOptions) {
		// 1、非http开头的需要拼接地址
		if (!options.url.startsWith('http')) {
			options.url = BASE_URL + options.url;
		}
		// 2、请求超时时间，默认60S，设置成10S
		options.timeout = 10000;
		console.log("http拦截：", options);
		// 3、添加请求头标识
		options.header = {
			...options.header,
			'requestDeviceType': 'Android'
		}
		// 4、添加token请求头标识
		const userinfo = uni.getStorageSync("userinfo");
		const token = userinfo?.token;
		if (token) {
			options.header.Authorization = token;
		}
	}
}

uni.addInterceptor('request', httpIntercepor);